package com.mes.common.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.ForeignKey;

import com.mes.basicdata.domain.Employee;

@MappedSuperclass
public class BasicModel implements Serializable{
	
	public final static int OBJECTSTATE_NONE = 0; // 未做任何处理
	public final static int OBJECTSTATE_TOBEADDED = 1;   // 添加
	public final static int OBJECTSTATE_TOBEUPDATED = 2; // 修改
	public final static int OBJECTSTATE_TOBEDELETED = 3; // 删除
	
	/**
	 * 
	 */
//	@Id
//	@GeneratedValue(generator = "uuid")
//  @GenericGenerator(name = "uuid", strategy = "assigned")
	@Transient
	protected String uuid;
	@Transient
	protected int objectState; 
	
	//@Column(name="CREATOR",length=50)
	@Transient
	protected String creatorUid;
	
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@Fetch(FetchMode.SELECT)
	@JoinColumn(name="CREATOR",insertable=false,updatable=false)
	protected Employee creator;
	
	@Column(name="CREATETIME",length=7)
	protected Date createTime = new Date();
	
	@Column(name="NOTES",length=50)
	protected String notes;
	
	@Transient
	protected Boolean isDelete;
	
//	@Column(name="OUT_UID")
//	protected String outUid;
	
	
	public String getUuid() {
		return uuid;
	}
	public void setUuid(String uuid) {
		this.uuid = uuid;
	}
	public int getObjectState() {
		return objectState;
	}
	public void setObjectState(int objectState) {
		this.objectState = objectState;
	}
	public String getCreatorUid() {
		return creatorUid;
	}
	public void setCreatorUid(String creatorUid) {
		this.creatorUid = creatorUid;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	public String getNotes() {
		return notes;
	}
	public void setNotes(String notes) {
		this.notes = notes;
	}
	public Employee getCreator() {
		return creator;
	}
	public void setCreator(Employee creator) {
		this.creator = creator;
	}
	public Boolean getIsDelete() {
		return isDelete;
	}
	public void setIsDelete(Boolean isDelete) {
		this.isDelete = isDelete;
	}
//	public String getOutUid() {
//		return outUid;
//	}
//	public void setOutUid(String outUid) {
//		this.outUid = outUid;
//	}
	
	@Override
	/**
	 * 浅克隆
	 */
	public Object clone() throws CloneNotSupportedException {
		// TODO Auto-generated method stub
		return super.clone();
	}
}
